<%-- 
    Document   : chatpage
    Created on : 15.12.2013, 20:54:16
    Author     : admin-pc
--%>

<%@page import="java.util.Map"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <script>
            function fresh() {
                location.reload();
            }
            setInterval("fresh()", 10000);
        </script>
    </head>
    <body>
        <jsp:useBean id="chat" scope="session" class="EJB.ChatEJB" />

        <form method="post" action="chatpage.jsp">
            <label for="message"></label>
            <input type="text" name="message">
            <input  type="submit" name="subm">
        </form>

        <%
            String msg = request.getParameter("message");
            if (msg == null) {
                msg = "";
            }
            chat.setMap(chat.getName(), chat.setMessages(msg));
            for (Map.Entry<?, ?> entry : chat.map.entrySet()) {
                if (entry.getKey().equals(chat.getName())) {
                    for (String item : chat.list) {
                        out.println(chat.getName() + " :" + item + "</br>");
                    }
                }
            }

        %>

    </body>
</html>
